Arch Linux上配置Clash代理 |
您所在的位置:网站首页 › Linux 安装clash › Arch Linux上配置Clash代理 |
换到Arch Linux后,我考虑使用AUR上的clash-verge,但是不是很好用,正好之前也有弃用这些第三方GUI的想法,于是就选择安装clash和clash-dashboard,clash-dashboard是一个简陋的用来web ui面板。 根据Clash wiki的描述,clash-for-windows以及clash-verge这样的客户端上的TUN功能是由Clash Premium core带来的,由于我个人原因,我选择了Clash core,而我又暂时懒得学习iptables之类的搞透明代理,所以我先选择设置环境变量来欺骗自己(KDE设置里的代理不够全局😢,印象中GNOME上的设置代理还是比较好用的😕)。 编辑~/.xprofile文件写入环境变量: 123456export all_proxy=http://127.0.0.1:7890export https_proxy=http://127.0.0.1:7890export http_proxy=http://127.0.0.1:7890export rsync_proxy=http://127.0.0.1:7890export no_proxy=127.0.0.1,localhostexport ftp_proxy=http://127.0.0.1:7890根据Arch zhwiki上的内容可以知道这是在dm登录进去会执行的脚本。 基础配置首先是安装它俩,clash是在官方软件仓库中的,而clash-dashboard只能在AUR中得到(或者你从GitHub看Readme安装也可以)。 按照Clash官方文档中的叙述应该在/etc/systemd/system/目录下创建文件clash.service,文件内容是: 1234567891011[Unit]Description=Clash daemon, A rule-based proxy in Go.After=network-online.target[Service]Type=simpleRestart=alwaysExecStart=/usr/bin/clash -d /etc/clash[Install]WantedBy=multi-user.target之后执行 12$ sudo systemctl daemon-reload$ sudo systemctl enable --now clash.servicesystemctl enable的时候如果没有后缀名默认是service,所以你不复制的话可以不用手敲.service()。 我选择安装AUR上的clash-dashboard,使用yay -Ql可以发现安装在了usr/share/clash-dashboard-git目录下。 可以使用wget url -O /etc/clash/config.yaml把机场提供的配置文件下载下来。 其中可能修改配置文件的(我认为配置文件应该没写,大抵应该得说在文件中添加): 1external-ui: /usr/share/clash-dashboard-git/ 定时更新配置文件我这里选择的不是corn计划任务,是systemd提供的corn的替代品。根据Arch zhwiki简单写了写 首先编写一个用于执行更新命令的service文件,我也就放在了clash.service同级目录中 1234567891011121314[Unit]Description=Get clash config.yaml.[Service]Type=oneshotExecStart=/bin/bash -c "wget --no-proxy \"https://xxx.xx\" -O config_tmp.yaml &&\sed -z -i 's/port: 7890\\nsocks-port: 7891/mixed-port: 7890/' config_tmp.yaml &&\sed -i 's/allow-lan: .*$/allow-lan: false/' config_tmp.yaml &&\sed -i '/external-controller: :9090/a external-ui: \/usr\/share\/clash-dashboard-git\/' config_tmp.yaml &&\sed -i 's/Rule/Global/' config_tmp.yaml &&\mv config_tmp.yaml /etc/clash/config.yaml"[Install]WantedBy=multi-user.target这么多sed就是因为配置文件我需要改一改,替换一些东西(悲),并且还需要添加ui目录(也就是clash-dashboard) 然后在同级目录编写一个同名的.timer文件: 123456789[Unit]Description=Run unit to get config.yaml which needed by clash[Timer]OnCalendar=dailyPersistent=true[Install]WantedBy=timers.target这里设置了是每天的凌晨零点执行一遍这个脚本,如果这个时候因为没开机的原因没执行上就在下一次开机执行它。具体可以参考上面给的wiki。 然后接着 12$ sudo systemctl daemon-reload$ sudo systemctl enable --now xxx.timer通过systemctl list-timers可以查看已有的定时器。 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |